package com.example.hotel.mapper;

//import org.springframework.data.repository.query.Param;
import com.example.hotel.dto.Room;
import com.example.hotel.dto.checkIn;
import com.example.hotel.dto.roomStatus;

import org.apache.ibatis.annotations.*;
@Mapper
public interface hotelMapper {
    // 获取房间状态
    @Select("SELECT * FROM room_status WHERE room_number = #{roomNumber}")
    roomStatus getRoomStatus(int roomNumber);

    // 插入入住记录
    @Insert("INSERT INTO check_in (room_number, name, id_number, start_time, end_time) " +
            "VALUES (#{roomNumber}, #{name}, #{idNumber}, #{startTime}, #{endTime})")
    void insertCheckIn(checkIn request);

    // 更新房间状态
    @Update("UPDATE room_status SET status = #{status} WHERE room_number = #{roomNumber}")
    void updateRoomStatus(@Param("roomNumber") int roomNumber, @Param("status") String status);

    // 更新房间打扫状态
    @Update("UPDATE room_status SET is_cleaned = #{isClean} WHERE room_number = #{roomNumber}")
    void updateRoomCleaningStatus(@Param("roomNumber") int roomNumber, @Param("isClean") boolean isClean);

    // 更新房间是否需要打扫
    @Update("UPDATE room_status SET needs_cleaning = #{needsCleaning} WHERE room_number = #{roomNumber}")
    void updateRoomNeedCleaning(@Param("roomNumber") int roomNumber, @Param("needsCleaning") boolean needsCleaning);

    // 删除入住记录
    @Delete("DELETE FROM check_in WHERE room_number = #{roomNumber}")
    void deleteCheckInByRoomNumber(int roomNumber);

    // 更新入住结束时间
    @Update("UPDATE check_in SET end_time = #{newEndTime} WHERE room_number = #{roomNumber}")
    void updateCheckInEndTime(@Param("roomNumber") int roomNumber, @Param("newEndTime") String newEndTime);

    //查询Wifi密码
    @Select("SELECT room_number as roomNumber, wifi_password as wifiPassword FROM room WHERE room_number = #{roomNumber}")
    Room getWifiPassWord(@Param("roomNumber") int roomNumber);

}
